<template>
	<view class="playback">
		<view class="video-block">
			<video :src="detail.videoUrl?'active':''" :autoplay="true" :http-cache="false" :play-strategy="2" class="video"></video>
		</view>
		<view class="title-block">
			<view class="title">{{detail.roomName}}</view>
			<view class="title-sub">{{detail.realName}}</view>
		</view>
		<view class="tab-block">
			<view class="tab-item" @click="tabActive=1" :class="tabActive==1?'active':''">直播介绍</view>
			<view class="tab-item" @click="tabActive=2" :class="tabActive==2?'active':''">热招职位</view>
			<view class="tab-item" @click="tabActive=3" :class="tabActive==3?'active':''">热门企业</view>
		</view>
		<view class="playback-content" :style="tabActive==1?'':'background:rgba(0,0,0,0);padding:0'">
			<template v-if="tabActive==1">
				<mp-html :content="detail.introduce" />
			</template>
			<template v-if="tabActive==2">
				<template v-if="publishList.length>0">
					<view
						@click="navigate('/page_other/job_hunting/job_detail/index?id='+item.id+'&jobType='+item.jobType)"
						class="position-item" v-for="(item,index) in publishList" :key="item.id">
						<view class="list-info">
							<view class="title-info">
								<view class="title">{{item.jobTitle}}</view>
								<view class="fast-job" v-if="item.worry==1">急招</view>
							</view>
							<view class="address">{{item.jobAddress}}</view>
							<view class="wage" v-if="item.minSalary">{{item.minSalary}}-{{item.maxSalary}}<text class="unit">元</text></view>
							<view class="wage" v-else>面议</view>
						</view>
					</view>
				</template>
				<view v-else class="empty">暂无数据</view>
			</template>
			<template v-if="tabActive==3">
				<template v-if="companyList.length>0">
					<view class="enterprise-item" @click="navigate('/page_other/company/company?id='+item.id)"
						v-for="(item,index) in companyList" :key="item.id">

						<view class="company-photo">
							<image :src="item.logoUrl" alt="">
						</view>
						<view class="company-info">
							<view class="company-name">{{ item.enterpriseName }}</view>
							<view class="company-other">{{ item.enterpriseIntroduction }}</view>
						</view>
					</view>
				</template>
				<view v-else class="empty">暂无数据</view>
			</template>
		</view>
	</view>
</template>

<script>
	import {
		getEndLive
	} from '@/api/live.js'
	export default {
		data() {
			return {
				tabActive: 1,
				detail: {
					coverUrl: '',
					realName: '',
					introduce: '',
					roomName: '',
					videoUrl: '',
				},
				companyList: [],
				publishList: [],
			}
		},
		methods: {
			navigate(url) {
				if (url) {
					uni.navigateTo({
						url
					})
				}
			},
			getDetail(roomNo) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getEndLive({
					roomNo
				}).then(data => {
					uni.hideLoading()
					this.detail = data.model;
					this.companyList = data.companyList;
					this.publishList = data.publishList
				}).catch(() => {
					uni.hideLoading()
					this.showToast('加载失败')
				})
			}
		},
		onLoad(e) {
			this.getDetail(e.roomNo)
		}
	}
</script>

<style lang="scss" scoped>
	.playback {
		width: 100%;
		padding-bottom: 20rpx;

		.video-block {
			width: 100%;
			height: 410rpx;

			.video {
				width: 100%;
				height: 100%;
			}
		}

		.title-block {
			padding: 30rpx;
			background: #fff;
			width: 100%;

			.title {
				font-size: 34rpx;
				font-weight: bold;
			}

			.title-sub {
				font-size: 28rpx;
				color: #333333;
				margin-top: 15rpx;
			}
		}

		.tab-block {
			margin: 0 auto;
			width: 540rpx;
			margin: 30rpx auto;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: 5px;
			border: 1px solid #fe7550;

			.tab-item {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 180rpx;
				height: 60rpx;
				font-size: 28rpx;
				color: #fe7550;
			}

			.tab-item.active {
				color: #fff;
				background-color: #fe7550;
			}
		}

		.playback-content {
			width: calc(100% - 60rpx);
			margin: 0 30rpx;
			padding: 30rpx;
			background: #fff;
			border-radius: 5px;
		}

		.enterprise-item {
			width: 100%;
			background: #fff;
			border-radius: 10rpx;
			box-shadow: 0 0 10px 0 #efefef;
			padding: 20rpx;
			margin-bottom: 30rpx;
			display: flex;
			align-items: center;
			.company-photo {
				width: 100rpx;
				height: 100rpx;
				border: 1px solid #f6f6f8;
				margin-right: 30rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.company-info {
				width: calc(100% - 130rpx);
				display: flex;
				flex-direction: column;
				justify-content: center;

				.company-name {
					font-size: 15px;
				}

				.company-other {
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					font-size: 12px;
					color: #999;
					margin-top: 10px;
				}
			}
		}

		.position-item {
			width: 100%;
			background: #fff;
			border-radius: 10rpx;
			box-shadow: 0 0 10px 0 #efefef;
			padding: 20rpx;
			display: flex;
			flex-direction: row;
			justify-content: center;
			margin-bottom: 40rpx;

			.detail-info {
				width: 260rpx;
				height: 200rpx;
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				justify-content: center;
				align-items: center;

				.name {
					width: 110rpx;
					font-size: 24rpx;
					color: #999;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					text-align: center;
					text-indent: 15rpx;
				}

				.photo {
					width: 70rpx;
					height: 70rpx;
					border-radius: 100%;
					background: #efefef;
				}

				.apply-btn {
					border: 1px solid #FE7526;
					border-radius: 8rpx;
					color: #FE7526;
					font-size: 24rpx;
					padding: 8rpx 28rpx;
					position: relative;
					left: 30rpx;
				}
			}

			.list-info {
				width: 100%;
				display: flex;
				flex-direction: column;

				>view {
					width: 100%;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.title-info {
					display: flex;
					flex-direction: row;
					align-items: center;

					.title {
						color: #000;
						font-weight: bold;
						font-size: 34rpx;
					}

					.fast-job {
						width: 60rpx;
						height: 38rpx;
						border: 1rpx solid #FE7526;
						font-size: 24rpx;
						text-align: center;
						color: #FE7526;
						margin-left: 20rpx;
						border-radius: 6rpx;
					}
				}

				.address {
					color: #999;
					font-size: 26rpx;
					margin-top: 20rpx;
				}

				.label-block {
					font-size: 24rpx;
					display: flex;
					flex-direction: row;
					flex-wrap: wrap;
					justify-content: left;
					margin-top: 20rpx;

					.label-item {
						padding: 8rpx 20rpx;
						background: #F5F6F8;
						color: #999;
						margin: 0 10rpx 20rpx 0;
					}
				}

				.wage {
					color: #FE7526;
					font-size: 36rpx;
					font-weight: bold;
					margin-top: 10px;

					.unit {
						font-size: 28rpx;
						font-weight: normal;
					}
				}
			}
		}
	}
</style>
